package com.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.RequestMapping;

import com.entity.User;
import com.service.UserService;

@Controller
public class UserController {
@Resource
private UserService userService;


@RequestMapping(value="/login")
public String login(User user,HttpSession session){
 User user1= userService.getUserByUsernameAndPassword(user);
   if(user1!=null){
	   System.out.println(user1.getUsername());
	   session.setAttribute("user1", user1);
	   
	return "redirect:/index?index=1";
   }else{
	   return "error";
   }
}
}
